<%@page import="hyl.ext.base.TokenFactory,hyl.ext.base.MyToken"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">

<meta
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
	name="viewport" />
<!-- 全局变量 函数定义区 见top.jsp -->
<%@ include file="pub/top.jsp"%>
<!-- 实例变量 函数定义区 -->
<%
//网页title String JSPTITLE="登录" ;
%>




<meta name="description" content="">
<meta name="author" content="">

<title>注册资源</title>

<link type="text/css" href="<%=basePath%>cssjs/login1/css/style.css"
	rel="stylesheet">
<link type="text/css" href="<%=basePath%>cssjs/layui/css/layui.css"
	rel="stylesheet">

<script src="<%=basePath%>cssjs/layui/layui.js"></script>
<script src="<%=basePath%>cssjs/jquery/zepto.min.js"></script>
<script src="<%=basePath%>cssjs/hyl/core/safe/md5.js"></script>
<style>
body {
	/*background-image: url("<%=basePath%>cssjs/login1/picture/1.jpg"); */
	background-repeat: no-repeat;
	/* 防止图片重复 */
	background-size: cover;
	/* 让图片铺满整个屏幕 */
	padding: 10px;
}
</style>
</head>

<body>


	<h1 class="h4">创建资源</h1>
	<form class="layui-form" action="">
		<div class="layui-form-item">
			<label class="layui-form-label">有效期</label>
			<div class="layui-input-block">


				<input type="text" class="layui-input" id="有效期"
					placeholder="有效期(分钟)">
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">资源</label>
			<div class="layui-input-block">
				<textarea id="资源" placeholder="资源URI" class="layui-textarea"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">密码</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" id="密码" placeholder="访问密码">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="button" id="btnreg" class="layui-btn">提交</button>
				<button type="button" id="btnmain" class="layui-btn ">退出</button>

			</div>
		</div>




		</div>

		</div>
</body>

</html>


<script type="module">
  import "<%=basePath%>cssjs/hyl/core/fun.js";
  import "<%=basePath%>cssjs/Mm.js";
  var URL_DAO_REGSRC = BASEPATH.concat("admin/regSrc");
 	var URL_DAO_REQSRC = BASEPATH.concat("u/reqSrc");
  var e能否提交 = false;
Mm.f刷新(HYLSessionKey,HYL_URLS);
console.log(Mm.readSM4())
  function message(e) {
    layer.msg(e, { icon: 0, anim: 5, time: 800 }, function () {
      // layer.msg('提示框关闭后的回调');
    });
  }
  $(document).ready(function () {
	
    $("#btnreg").click(function () {
	 let 有效期 = $("#有效期").val(); 
	 let 资源 = $("#资源").val();
	 let 密码 = $("#密码").val();
	 资源 = encodeURIComponent(资源);
     let param = {有效期:有效期,pass:密码,user :<%=tk.getUserId()%>,src:资源};
	 let str=       Mm.sm4加密( JSON.stringify(param));
	 _Fun.postJson(URL_DAO_REGSRC, { HYLSessionKey: HYLTokeId }, {mm:str}, function(dtext) {
				var dd = JSON.parse(dtext);
				if (dd.code == 1) {		
					console.log(dtext);		
					var obj= JSON.parse(dd.msg);
					let parm2=     Mm.sm4加密( obj.token+','+obj.s密钥);
					console.log(obj.token+','+obj.s密钥);	
					_Fun.postJson(URL_DAO_REQSRC, { HYLSessionKey: HYLTokeId }, {mm:parm2}, function(dtext2) {
						console.log(dtext2);		

					});
			
				} else {
					console.log(dd.msg);
				}
			}, function(code, error) {
				console.log({ code: code, err: error });

			});
    });
  });



</script>